package com.ymatou.iapi.csim.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.SendMessageBean;
import com.ymatou.iapi.csim.parameter.UpdateSessionMarkBean;
import com.ymatou.iapi.csim.service.SendMessageCall;
import com.ymatou.iapi.csim.service.UpdateSessionMarkCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_cssession;
import com.ymttest.database.sqlwapper.CSIM.ymt_cssessionWapper;
import com.ymttest.database.sqlwapper.CSIM.ymt_csstatuslogWapper;
import com.ymttest.database.sqlwapper.CSIM.ymt_onlinecsWapper;
import com.ymttest.database.sqlwapper.CSIM.ymt_queuesessionWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
/**
*更新会话标记
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_UpdateSessionMark{
	private static UpdateSessionMarkBean bean;
	private static UpdateSessionMarkCall call;
	private CsimCallService service=new CsimCallService(); 
	private Integer csId=Integer.parseInt(EnvSetup.getData("csId").toString());
	private static Integer userId=Integer.parseInt(EnvSetup.getData("userId_IM").toString());
	private static ymt_cssessionWapper csSessionWapper=new ymt_cssessionWapper();
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("更新会话标记");
	}

	@Before
	public void caseUp() {
		bean=new UpdateSessionMarkBean();
		call=new UpdateSessionMarkCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateSessionMark_1() {
		Logger.start(true,"更新会话标记");
		try {
			//查询是否有在线客服 1，2
    		service.getOnlineCS();
    		//打开会话
    		ymt_cssession csSession=service.getOpenSession(csId,userId);
			bean.setSessionId(csSession.getId());
			bean.setMark(1);

			call.setData(bean);
			call.callService();	
			//验证
			ymt_cssession cssession=csSessionWapper.selectByPrimaryKey(csSession.getId());
			Logger.verifyEquals(bean.getMark(), cssession.getMark(), "验证Mark更改正确");
			Logger.verifyEquals("0", call.getResult().get("ErrorCode").toString(), "验证errorCode");
			Logger.verifyEquals(true, call.getResult().get("Success"), "验证Success");
			Logger.verifyEquals("200", call.getStatus(), "验证Status");
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}